<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        div {
            width: 200px;
            height: 200px;
            background-color: #f00;
            position: absolute;
            left: 0;
        }
    </style>
</head>

<body>

    <div></div>

    <script>

        // 一个盒子从左边移动到右边   实际上就是 left在改变


        // 获取样式
        //    oDiv.style.left  获取left值   但是只能获取行内样式
        //    getComputedStyle(oDiv).left   获取left值   可以获取任意样式  --- 注意会带单位




        var oDiv = document.querySelector('div');


        var _left = parseInt(getComputedStyle(oDiv).left);
        console.log(_left);

        var speed = 1;

        var t = setInterval(function () {
            speed++;
            _left += speed;
            oDiv.style.left = _left + 'px';
            if (_left >= 1300) {
                oDiv.style.left = 1300 + 'px';
                clearInterval(t);
            }
        }, 30)


    </script>

</body>

</html>